struct CreateMomentRequest{
    1: PostContent content (api.body="content");   // 发表内容
}

struct CreateMomentResponse{
    1: Meta meta;
    2: Moment moment; // 动态
}

struct Moment{
    1: i64 moment_id;          // 动态id
    2: i64 user_id;            // 用户id
    3: PostContent content;    // 发表内容
    4: string view_count;      // 浏览量文案, 形如"1.1k浏览"、"24个人看过"
    5: i64 comment_count;      // 评论数
    6: i64 like_count;         // 点赞数
    7: string create_time;     // 创建时间, 形如"2006-01-02"
    8: string nickname;        // 用户昵称
    9: string head_url;        // 用户头像链接
    10: bool i_like_it;        // 当前登陆用户是否点赞
}

struct PostContent {
    1: string text;             // 文本
    2: list<string> image_urls; // 图片链接list
}

struct DeleteMomentRequest{
    1: i64 moment_id (api.path="moment_id"); // 动态id
}

struct DeleteMomentResponse{
    1: Meta meta;
}

struct GetMomentDetailRequest{
    1: i64 moment_id (api.path="moment_id") // 动态id
}

struct GetMomentDetailResponse{
    1: Moment moment;
}

struct GetMomentsRequest{
    1: i32 limit (api.query="limit");
    2: i32 offset (api.query="offset");
}

struct GetMomentsResponse{
    1: Meta meta;
    2: list<Moment> moments; // 这么设计, 返回的结构体会不会冗余信息太多?
    3: i64 total;
}

struct Meta{
    1: i32 code;    // 业务自定义的返回值, 0为成功, 其他情况为失败(20018为未登录)
    2: string msg;
}

// 单文件上传
// e.g. 如果要上传demo.png文件, 请求如下:
// curl --request POST 'asueeer.com/nearby/upload_image?mock_login=123' --form 'file=@"/demo.png"'
// 参考: https://www.kancloud.cn/shuangdeyu/gin_book/949420
struct UploadImageRequest {
    1: File file (api.body="file");
}

struct File {}

struct UploadImageResponse{
    1: Meta meta;
    2: string image_url;
}

// 多文件上传
// e.g. 如果要上传[demo1.png, demo2.png]两个图片文件, 则请求如下:
// curl --request POST 'localhost:8090/upload_images?mock_login=123' \
// --form 'files=@"demo1.png"' \
// --form 'files=@"demo2.png"'
// 参考: https://www.kancloud.cn/shuangdeyu/gin_book/949420
struct UploadImagesRequest{
    1: list<File> files (api.body="files");
}

struct UploadImagesResponse{
    1: Meta meta;
    2: list<string> image_urls;
}

service MomentService{
    // 动态
    CreateMomentResponse CreateMoment(1: CreateMomentRequest req) (api.post="/nearby/moment")
    GetMomentsResponse GetMoments(1: GetMomentsRequest req) (api.get="/nearby/moments")
    GetMomentDetailResponse GetMomentDetail(1: GetMomentDetailRequest req) (api.get="/nearby/moment/:moment_id")
    DeleteMomentResponse DeleteMoment(1: DeleteMomentRequest req) (api.delete="/nearby/moment/:moment_id")

    // 图片上传(单文件)
    UploadImageResponse UploadImage(1: UploadImageRequest req) (api.post="/nearby/upload_image")
    // 图片上传(多文件)
    UploadImagesResponse UploadImages(1: UploadImagesRequest req) (api.post="/nearby/upload_images")
}